<?php 

/**
 * 提现申请表
 * @author Gao Zongwei
 *
 */
class WalletWithdraw extends Eloquent{
	
	
	protected $table = "wallet_withdraw";
	// 提现状态(status)
	const STATUS_SUCCESS = 'success';	// 提现成功
	const STATUS_FAIL = 'fail';			// 提现失败
	const STATUS_WAIT = 'wait';			// 提现中
	
	/**
	 * 
	 * @param array $data
	 */
	public static function _createWithdraw($data){
		$record = new WalletWithdraw();
		$record->user_id = Auth::user()->id;
		$record->money = $data['money'];
		$record->user_name = $data['user_name'];
		$record->brank_name = $data['brank_name'];
		$record->card_id = $data['card_id'];
		$record->contact_phone = $data['contact_phone'];
		$record->status = self::STATUS_WAIT;
		$record->save();
		return $record->toArray();
	}
	
	/**
	 * 变更提现状态
	 */
	public function makeFail($id, $status){
		$record = self::find($id);
		if($record){
			return (bool)$record->status = $status;
		}
		return false;
	}
}